<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Contract-info</title>
    <!-- 引入layui 样式-->
    <link rel="stylesheet" href="../../static/css/style.css"/>
    <link rel="stylesheet" href="../../static/layer/css/layui.css"/>
    <link rel="stylesheet" href="../../static/css/font-awesome.min.css">
    <link rel="stylesheet" href="../../static/ucss/contract/contract-info.css"/>
</head>
<style>
    .layui-form-label {
        width: 100px;
    }
</style>
<body>
<form class="layui-form">
    <div class="layui-tab layui-tab-brief" lay-filter="contractInfoTabBrief">
        <ul class="layui-tab-title">
            <li class="layui-this">合同信息</li>
            <!--<li>审核流程</li>-->
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <div class="tab-body">
                    <div>
                        <div class="quote-submit-person">
                            <span class="fl">合同编号： <span class="CONTRACT_NUM"></span></span>
                            <span class="fr">提交人： <span class="submit_person_name"></span></span>
                            <span class="clr fr">签订日期： <span class="con_date"></span></span>
                        </div>
                        <!--基本信息-->
                        <div class="quote-info">
                            <div class="quote-title">
                                <i class="fa fa-circle-o" aria-hidden="true"></i>
                                <span>借款方信息</span>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-row" style="margin-left: 50px;margin-bottom: 10px">
                                    <div class="layui-col-md4">
                                        公司名：<span class="company_name"></span>
                                    </div>
                                    <div class="layui-col-md4">
                                        统一社会信用代码：<span class="BUSS_CODE"></span>
                                    </div>
                                    <div class="layui-col-md4">
                                        行业类别：<span class="industry_name"></span>
                                    </div>
                                </div>

                                <div class="layui-row" style="margin-left: 50px;margin-bottom: 10px">
                                    <div class="layui-col-md4">
                                        公司类型：<span class="COMPANY_TYPE"></span>
                                    </div>
                                    <div class="layui-col-md4">
                                        注册资金(认缴)：<span class="REG_CAPITAL"></span> 万元
                                    </div>
                                    <div class="layui-col-md4">
                                        注册资金(实缴)：<span class="REG_CAPITAL_PAY"></span> 万元
                                    </div>
                                </div>

                                <div class="layui-row" style="margin-left: 50px;margin-bottom: 10px">
                                    <div class="layui-col-md4">
                                        法人：<span class="legal_person_name"></span>
                                    </div>
                                    <div class="layui-col-md4">
                                        联系电话：<span class="legal_person_tel"></span>
                                    </div>
                                </div>
                                <div class="layui-row" style="margin-left: 50px;margin-bottom: 10px">
                                    <div class="layui-col-md4">
                                        签订人：<span class="signer"></span>
                                    </div>
                                    <div class="layui-col-md4">
                                        联系电话：<span class="signer_tel"></span>
                                    </div>
                                </div>
                                <div class="layui-row" style="margin-left: 50px;margin-bottom: 10px">
                                    <div class="layui-col-md4">
                                        注册地址：<span class="REG_ADDRESS"></span>
                                    </div>
                                    <div class="layui-col-md4">
                                        经营地址：<span class="BUSINESS_ADDRESS"></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--财务信息-->
                        <div class="quote-info">
                            <div class="quote-title">
                                <i class="fa fa-circle-o" aria-hidden="true"></i>
                                <span>财务信息</span>
                            </div>
                            <div class="layui-form-item">
                                <div class="quote-contract-info">
                                    <div class="" style="display: flex;align-items: center;">
                                        <span>数据日期</span>
                                        <div class="" style="margin-left: 20px">
                                            <span type="text" id="DATA_START"></span>至
                                            <span type="text" id="DATA_END"></span>
                                        </div>
                                    </div>
                                    <div class="layui-form">
                                        <table class="layui-table">
                                            <colgroup>
                                                <col width="150">
                                                <col width="150">
                                                <col width="200">
                                            </colgroup>
                                            <thead>
                                            <tr>
                                                <th style="width: 30%;">名称</th>
                                                <th style="width: 40%;">计算公式</th>
                                                <th style="width: 30%;">比值率</th>
                                            </tr>
                                            </thead>
                                            <tbody class="tbody">
                                            <tr id="tab_jisuan">
                                                <td>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-inline">
                                                            资产负债率
                                                        </div>
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="layui-inline">
                                                        <div class="">
                                                            负债总额\资产总额*100%
                                                        </div>
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-inline">
                                                            <span type="number" name="ASSET_LIABILITY"
                                                                  id="ASSET_LIABILITY" value=""
                                                                  style="text-align: right"></span>
                                                        </div>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr id="tab_jisuan">
                                                <td>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-inline">
                                                            流动比率
                                                        </div>
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="layui-inline">
                                                        <div class="">
                                                            流动资产合计\流动负债合计*100%
                                                        </div>
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-inline">
                                                            <span type="number" name="LIQUIDITY" id="LIQUIDITY" value=""
                                                                  style="text-align: right"></span>
                                                        </div>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr id="tab_jisuan">
                                                <td>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-inline">
                                                            速动比率
                                                        </div>
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="layui-inline">
                                                        <div class="">
                                                            （流动资产合计-存货）\流动负债合计*100%
                                                        </div>
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-inline">
                                                            <span type="number" name="QUICK_RATIO" id="QUICK_RATIO"
                                                                  value="" style="text-align: right"></span>
                                                        </div>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr id="tab_jisuan">
                                                <td>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-inline">
                                                            销售利润率
                                                        </div>
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="layui-inline">
                                                        <div class="">
                                                            利润总额\营业收入*100%
                                                        </div>
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="layui-inline">
                                                        <div class="layui-input-inline">
                                                            <span type="number" name="PROFIT" id="PROFIT" value=""
                                                                  style="text-align: right"></span>
                                                        </div>
                                                    </div>
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--借款企业信息-->
                        <div class="quote-info">
                            <div class="quote-title">
                                <i class="fa fa-circle-o" aria-hidden="true"></i>
                                <span>借款企业信息</span>
                            </div>
                            <div class="layui-form-item">
                                <!--企业信息-->
                                <div class="quote-tenant-info">
                                    <div class="tenant-box">
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">行业预警</label>
                                                <div class="layui-input-inline">
                                                    <select name="HYYJ" lay-filter="">
                                                        <option value="支持行业">支持行业</option>
                                                        <option value="维护行业">维护行业</option>
                                                        <option value="高危行业">高危行业</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <label class="layui-form-label">社会主体评级</label>
                                                <div class="layui-input-inline">
                                                    <select name="SHZTPJ" lay-filter="">
                                                        <option value="无">无</option>
                                                        <option value="A">A</option>
                                                        <option value="AA">AA</option>
                                                        <option value="AAA">AAA</option>
                                                        <option value="B">B</option>
                                                        <option value="BB">BB</option>
                                                        <option value="BBB">BBB</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <label class="layui-form-label">税务评级</label>
                                                <div class="layui-input-inline">
                                                    <select name="SWPJ">
                                                        <option value="A">A</option>
                                                        <option value="B">B</option>
                                                        <option value="C">C</option>
                                                        <option value="D">D</option>
                                                        <option value="M">M</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <label class="layui-form-label">企业风险</label>
                                                <div class="layui-input-inline">
                                                    <select name="QYFX" lay-filter="">
                                                        <option value="无提示风险">无提示风险</option>
                                                        <option value="普通风险">普通风险</option>
                                                        <option value="警示风险">警示风险</option>
                                                        <option value="严重风险">严重风险</option>
                                                    </select>
                                                </div>
                                            </div>

                                            <div class="layui-inline">
                                                <label class="layui-form-label">企业状态</label>
                                                <div class="layui-input-inline">
                                                    <input type="radio" name="QYZT" value="0" title="正常"
                                                           lay-filter="" checked="">
                                                    <input type="radio" name="QYZT" value="1" title="异常"
                                                           lay-filter="">
                                                </div>
                                            </div>

                                            <div class="layui-inline">
                                                <label class="layui-form-label">欠税情况</label>
                                                <div class="layui-input-inline">
                                                    <input type="radio" name="QSQK" value="0" title="无"
                                                           lay-filter="" checked="">
                                                    <input type="radio" name="QSQK" value="1" title="有"
                                                           lay-filter="">
                                                </div>
                                            </div>

                                            <div class="layui-inline">
                                                <label class="layui-form-label">欠缴社保</label>
                                                <div class="layui-input-inline">
                                                    <input type="radio" name="QJSB" value="0" title="无"
                                                           lay-filter="" checked="">
                                                    <input type="radio" name="QJSB" value="1" title="有"
                                                           lay-filter="">
                                                </div>
                                            </div>

                                            <div class="layui-inline">
                                                <label class="layui-form-label">行政处罚记录</label>
                                                <div class="layui-input-inline">
                                                    <input type="radio" name="XZCFJL" value="0" title="无"
                                                           lay-filter="" checked="">
                                                    <input type="radio" name="XZCFJL" value="1" title="有"
                                                           lay-filter="">
                                                </div>
                                            </div>

                                            <div class="layui-inline">
                                                <label class="layui-form-label">法院诉讼信息</label>
                                                <div class="layui-input-inline">
                                                    <input type="radio" name="FYSSXX" value="0" title="无"
                                                           lay-filter="" checked="">
                                                    <input type="radio" name="FYSSXX" value="1" title="有"
                                                           lay-filter="">
                                                </div>
                                            </div>

                                            <div class="layui-inline">
                                                <label class="layui-form-label">法院强制执行</label>
                                                <div class="layui-input-inline">
                                                    <input type="radio" name="FYQZZX" value="0" title="无"
                                                           lay-filter="" checked="">
                                                    <input type="radio" name="FYQZZX" value="1" title="有"
                                                           lay-filter="">
                                                </div>
                                            </div>

                                            <div class="layui-inline">
                                                <label class="layui-form-label">对外担保</label>
                                                <div class="layui-input-inline">
                                                    <input type="radio" name="DWDB" value="0" title="无"
                                                           lay-filter="" checked="">
                                                    <input type="radio" name="DWDB" value="1" title="有"
                                                           lay-filter="">
                                                </div>
                                            </div>

                                            <div class="layui-inline">
                                                <label class="layui-form-label">对外担保不良</label>
                                                <div class="layui-input-inline">
                                                    <input type="radio" name="DWDBBL" value="0" title="无"
                                                           lay-filter="" checked="">
                                                    <input type="radio" name="DWDBBL" value="1" title="有"
                                                           lay-filter="">
                                                </div>
                                            </div>

                                            <div class="layui-inline">
                                                <label class="layui-form-label">逾期贷款</label>
                                                <div class="layui-input-inline">
                                                    <input type="radio" name="YQDK" value="0" title="无"
                                                           lay-filter="" checked="">
                                                    <input type="radio" name="YQDK" value="1" title="有"
                                                           lay-filter="">
                                                </div>
                                            </div>

                                            <div class="layui-inline">
                                                <label class="layui-form-label">他行逾期贷款</label>
                                                <div class="layui-input-inline">
                                                    <input type="radio" name="THYQDK" value="0" title="无"
                                                           lay-filter="" checked="">
                                                    <input type="radio" name="THYQDK" value="1" title="有"
                                                           lay-filter="">
                                                </div>
                                            </div>

                                            <div class="layui-inline">
                                                <label class="layui-form-label">抵押物权属清晰</label>
                                                <div class="layui-input-inline">
                                                    <input type="radio" name="DYWQSQX" value="0" title="无"
                                                           lay-filter="" checked="">
                                                    <input type="radio" name="DYWQSQX" value="1" title="有"
                                                           lay-filter="">
                                                </div>
                                            </div>

                                            <div class="layui-inline">
                                                <label class="layui-form-label">关联企业不良</label>
                                                <div class="layui-input-inline">
                                                    <input type="radio" name="GLQYBL" value="0" title="无"
                                                           lay-filter="" checked="">
                                                    <input type="radio" name="GLQYBL" value="1" title="有"
                                                           lay-filter="">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--合同信息-->
                        <div class="quote-info">
                            <div class="quote-title">
                                <i class="fa fa-circle-o" aria-hidden="true"></i>
                                <span>合同信息</span>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-row" style="margin-left: 50px;margin-bottom: 10px">
                                    <div class="layui-col-md4">
                                        借款金额：<span class="loan_price"></span> 元
                                    </div>
                                    <div class="layui-col-md4">
                                        合同期限：<span class="con_hr_date"></span>至<span class="con_end_date"></span>
                                    </div>
                                </div>

                                <div class="layui-row" style="margin-left: 50px;margin-bottom: 10px">
                                    <div class="layui-col-md4">
                                        借款利率：<span class="BORROW_INTEREST_RATE"></span>%/天
                                    </div>
                                    <div class="layui-col-md4">
                                        合同签订日：<span class="con_date"></span>
                                    </div>
                                </div>

                                <div class="layui-row" style="margin-left: 50px;margin-bottom: 10px">
                                    <div class="layui-col-md4">
                                        备注信息：<span class="contract_info"></span>
                                    </div>
                                    <div class="layui-col-md4">
                                        滞纳金利率：<span class="LATE_PAYMENT_RATE"></span>%/天
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="quote-info quote-throw-lease">
                            <div class="quote-title">
                                <i class="fa fa-circle-o" aria-hidden="true"></i>
                                <span>退租信息</span>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline layui-inline-long">
                                    <label class="layui-form-label">退租类型：</label>
                                    <div class="layui-input-inline">
                                        <span class="tuizu-type"></span>
                                    </div>
                                </div>
                                <div class="layui-inline layui-inline-long">
                                    <label class="layui-form-label">退租日期：</label>
                                    <div class="layui-input-inline">
                                        <span class="tuizu-date"></span>
                                    </div>
                                </div>
                                <div class="layui-inline layui-inline-long">
                                    <label class="layui-form-label">退租原因：</label>
                                    <div class="layui-input-inline tuizu-reason">
                                    </div>
                                </div>
                                <div class="layui-inline layui-inline-long">
                                    <label class="layui-form-label">退租备注：</label>
                                    <div class="layui-input-inline">
                                        <span class="tuizu-info"></span>
                                    </div>
                                </div>
                                <div class="layui-inline layui-inline-long">
                                    <label class="layui-form-label">退租费用：</label>
                                    <div class="layui-input-inline tuizu-fee">
                                    </div>
                                    <div class="layui-input-inline" style="margin-left: 110px;">
                                        <span class="tuizu-total"></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--详细账单-->
                        <div class="quote-info quote-rent-detail">
                            <div class="quote-title">
                                <i class="fa fa-circle-o" aria-hidden="true"></i>
                                <span>详细账单</span>
                            </div>
                            <div class="quote-rent-detail-list">
                                <ul class="container-rent-detail-list">
                                    <li>
                                        <div>
                                            <span>区间</span>
                                            <span></span>
                                        </div>
                                        <div>
                                            <span>还款日</span>
                                            <span></span>
                                        </div>
                                        <div>
                                            <span>最终金额</span>
                                            <span class="label-unit-money">元</span>
                                        </div>
                                        <div>
                                            <span>滞纳金</span>
                                            <span class="label-unit-money">元/天</span>
                                        </div>
                                        <div>
                                            <span>类型</span>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </div>
                        <!--附件-->
                        <div class="quote-info">
                            <div class="quote-title">
                                <i class="fa fa-circle-o" aria-hidden="true"></i>
                                <span>附件</span>
                            </div>
                            <div>
                                <div class="layui-form-item">
                                    <div class="layui-inline layui-inline-normal attachments">
                                        <!--<div class="layui-input-inline">
                                            <span>1</span>
                                            <span>附件1</span>
                                            <span>下载</span>
                                        </div>-->
                                    </div>
                                    <div class="layui-upload-list">
                                        <table class="layui-table">
                                            <thead>
                                            <tr>
                                                <!--<th>文件类型</th>-->
                                                <th>文件类型</th>
                                                <th>文件名</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody id="demoList"></tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>




                        <div class="quote-info">
                            <div class="quote-title">
                                <i class="fa fa-circle-o" aria-hidden="true"></i>
                                <span>其他信息</span>
                                <div class="layui-input-block">
                                    <a class="layui-btn class_is_title" onclick="toContractQtAdd(this)">点击录入</a>
                                </div>
                            </div>

                        </div>


                    </div>
                </div>
            </div>
            <div class="layui-tab-item">
                <!--审核人-->
                <div class="quote-info">
                    <blockquote class="layui-elem-quote layui-text">审核详情:</blockquote>
                    <div class="layui-tab-item layui-show">
                        <div class="quote-info">
                            <table id="historySH"></table>
                        </div>
                    </div>
                </div>
            </div>


        </div>




    </div>
    <blockquote class="blockquote-bottom">
        <div class="blockquote-bottom-item">
            <span class="shenhe">
            </span>
            <!--<a class="layui-btn layui-btn-small layui-btn-normal" onclick="operate.print(this);">打印</a>-->
            <a class="layui-btn layui-btn-small " onclick="operate.cancel(this);">取消</a>
        </div>
    </blockquote>
</form>
<script type="text/javascript" src="../../static/layer/layui.js"></script>
<script type="text/javascript" src="../../static/js/common/dateUtils.js"></script>
<script type="text/javascript" src="../../static/js/common/typeUtils.js"></script>
<script type="text/javascript" src="../../static/js/common/queryUtils.js"></script>
<script>
    var $, element, layer, laydate, form;
    var today = DateUtils.dateFormat(new Date(), "yyyy-MM-dd"); // 今天的日期
    var contractId = QueryUtils.GetQueryString("CONTRACT_ID");
    var button = QueryUtils.GetQueryString("button");//按钮审核页面跳转
    var checkType = QueryUtils.GetQueryString("type");
    var IS_TITLE = QueryUtils.GetQueryString("IS_TITLE");
    //alert(checkType);
    layui.use(['jquery', 'element', 'layer', 'laydate', 'form', 'upload', 'table'], function () {
        // 加载元素控件
        $ = layui.jquery, element = layui.element, layer = layui.layer, laydate = layui.laydate, form = layui.form, table = layui.table;
        if(IS_TITLE=="show"){
            $(".class_is_title").html("查看详情");
        }
        // 合同ID

        // var contractId = 'a6aa00c80df54b33a3e795174862e7f7';
        //初始化审核按钮是否有权限
        if ("shenhe" == button) {
            $(".shenhe").html(" <a class=\"layui-btn layui-btn-small\" onclick=\"operate.pass();\">通过</a>\n" +
                "            <a class=\"layui-btn layui-btn-small layui-btn-danger\" onclick=\"operate.reject(this);\">驳回</a>");
        }
        init.initContractInfo(contractId);
        init.initAtt(contractId);

        //加载审核详细
        //操作详情
        var data = {};
        data.CONTRACT_ID = contractId;
        //alert(data.CONTRACT_ID);
        table.render({
            elem: '#historySH'
            , url: '/recordController/list'
            , where: data
            , cols: [[
                {field: 'DETAILS', event: 'setSign', title: '操作详情', width: 300}
                , {field: 'OPERATOR', event: 'setSign', title: '操作人', width: 150}
                , {field: 'OPERA_TIME', event: 'setSign', title: '操作时间', width: 150}

            ]]
            , id: ''
            , page: true
            , height: 'auto'
            , limit: '10'
            , size: 'sm' //小尺寸的表格
        });
    });
    /**
     * 初始化方法集合
     * 使用： init.function()
     * param: obj传this，调用该方法的对象
     *
     */
    var init = {
        // 通过合同ID获取合同详情
        initContractInfo: function (id) {
            $.ajax({
                url: "/LoanController/info",
                data: {ID: id},
                dataType: "json",
                type: "post",
                async: false,
                success: function (res) {
                    if (res.errcode === "0") {
                        init.setValue(res.data);
                    } else if (res.errcode === "1") {
                        layer.msg(res.errmsg, function () {
                        });
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.error(XMLHttpRequest.status);
                    console.error(XMLHttpRequest.readyState);
                    console.error(textStatus);
                }
            });
        },
        // 加载合同 房屋 和抵押物信息
        initAtt: function (id) {
            //抵押 房屋 附件
            //初始化房屋 和抵押物附件
            $.ajax({
                url: "/recordController/attlist",
                data: {CONTRACT_ID: id},
                dataType: "json",
                type: "post",
                async: false,
                success: function (res) {
                    if (res.errcode === "0") {
                        if (!!res.data.attachment) {
                            var attachment = res.data.attachment;
                            for (var i = 0; i < attachment.length; i++) {
                                if (!!attachment[i].PATH) {
                                    /*var str = `<div class="layui-input-block">
                                                  <span>${attachment[i].REMARK}</span>
                                                    <span>${attachment[i].TYPE}</span>
                                                  <img width="100px" height="100px" src="http://${window.location.host}${attachment[i].PATH}" title="${attachment[i].NAME}">
                                                  <span><a href="http://${window.location.host}${attachment[i].PATH}" target="_blank" class="layui-btn layui-btn-mini layui-btn-normal">下载</a></span>
                                              </div>`;
                                    $(".attachments").append(str);*/
                                    var demoListView = $('#demoList');
                                    var tr = $(['<tr id="upload-' + (i + 1) + '">'
                                        , '<td>' + attachment[i].REMARK + '</td>'
                                        , '<td>' + attachment[i].NAME + '</td>'
                                        , '<td>'
                                        , '<a href="http://' + window.location.host + '/' + attachment[i].PATH + '" target="_blank" class=\"layui-btn layui-btn-mini layui-btn-normal\">下载</a>'
                                        , '</td>'
                                        , '</tr>'].join(''));
                                    demoListView.append(tr);
                                }

                            }

                        }
                    } else if (res.errcode === "1") {
                        layer.msg(res.errmsg, function () {
                        });
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.error(XMLHttpRequest.status);
                    console.error(XMLHttpRequest.readyState);
                    console.error(textStatus);
                }
            });
        },
        // 赋值
        setValue: function (data) {
            // console.log(data);
            var contract = data.contract;
            var contact = data.contact;
            var discount = data.discount;
            var bill = data.bill;
            var attachment = data.attachment;
            var initRead = data.initRead;
            var bl = data.BL;
            $(".loan_price").html(QueryUtils.fixedThousand(contract.LOAN_PRICE, 2));//借款金额
            $(".submit_person_name").html(contract.SUBMIT_PERSON_NAME);
            $(".CONTRACT_NUM").html(contract.CONTRACT_NUM);
            $(".con_date").html(contract.CON_DATE);

            if (contract.LEASE == 0) {
                // $(".legal_person_name").html(contract.LEGAL_PERSON_NAME);
                // $(".legal_person_tel").html(contract.LEGAL_PERSON_TEL);
            } else if (contract.LEASE == 1) {
                $(".company_name_type").html("姓名：");
                $(".business_license_type").html("身份证号：");
                $(".legal_person").remove();
            }
            $(".legal_person_name").html(contract.LEGAL_PERSON_NAME);//法人
            $(".legal_person_tel").html(contract.LEGAL_PERSON_TEL);//联系电话
            $(".company_name").html(contract.COMPANY_NAME);
            $(".byname").html(contract.BYNAME);
            $(".industry_name").html(contract.INDUSTRY_NAME);
            $(".business_license").html(contract.BUSINESS_LICENSE);
            $(".signer").html(contract.SIGNER);
            $(".signer_tel").html(contract.SIGNER_TEL);
            $(".contract_address").html(contract.CONTRACT_ADDRESS);
            $(".contract_info").html(contract.INFO);
            $(".BUSS_CODE").html(contract.BUSINESS_LICENSE);
            $(".COMPANY_TYPE").html(contract.COMPANY_TYPE);
            $(".REG_CAPITAL").html(contract.REG_CAPITAL);
            $(".REG_CAPITAL_PAY").html(contract.REG_CAPITAL_PAY);
            $(".REG_ADDRESS").html(contract.REG_ADDRESS);
            $(".BUSINESS_ADDRESS").html(contract.BUSINESS_ADDRESS);
            $(".BORROW_INTEREST_RATE").html(contract.BORROW_INTEREST_RATE);
            $(".LATE_PAYMENT_RATE").html(contract.LATE_PAYMENT_RATE);
            $(".contacts").empty();
            if (!!contact) {
                for (var i = 0; i < contact.length; i++) {
                    var str = '<div class="layui-inline layui-inline-normal">\n' +
                        '          <label class="layui-form-label">联系人：</label>\n' +
                        '          <div class="layui-input-inline">\n' +
                        '              <span>' + contact[i].CONTACTS_NAME + '</span>\n' +
                        '          </div>\n' +
                        '      </div>\n' +
                        '      <div class="layui-inline layui-inline-short">\n' +
                        '          <label class="layui-form-label">联系电话：</label>\n' +
                        '          <div class="layui-input-inline">\n' +
                        '              <span>' + contact[i].CONTACTS_TEL + '</span>\n' +
                        '          </div>\n' +
                        '      </div>';
                    $(".contacts").append(str);
                }
            }

            //初始化贷款信息
            var tb_financial = data.tb_financial;
            if (!!tb_financial) {
                tb_financial.ASSET_LIABILITY && $("#ASSET_LIABILITY").html(tb_financial.ASSET_LIABILITY + "%"); //资产负债率
                tb_financial.LIQUIDITY && $("#LIQUIDITY").html(tb_financial.LIQUIDITY + "%"); //流动比率
                tb_financial.QUICK_RATIO && $("#QUICK_RATIO").html(tb_financial.QUICK_RATIO + "%");  //速动比率
                tb_financial.PROFIT && $("#PROFIT").html(tb_financial.PROFIT + "%");//销售利润率
                tb_financial.DATA_START && $("#DATA_START").html(tb_financial.DATA_START.substring(0, 7));//销售利润率
                tb_financial.DATA_END && $("#DATA_END").html(tb_financial.DATA_END.substring(0, 7));//销售利润率
            }

            //初始化借款企业信息
            let tb_loan_company = data.tb_loan_company;
            if (!!tb_loan_company) {
                for (let i in tb_loan_company) {
                    init.initCompanyValue(i, tb_loan_company[i]);
                }
                $("select[name='HYYJ']").val(tb_loan_company.HYYJ).attr("disabled", "disabled");
                $("select[name='SHZTPJ']").val(tb_loan_company.SHZTPJ).attr("disabled", "disabled");
                $("select[name='SWPJ']").val(tb_loan_company.SWPJ).attr("disabled", "disabled");
                $("select[name='QYFX']").val(tb_loan_company.QYFX).attr("disabled", "disabled");
            }

            $(".con_hr_date").html(contract.CON_HR_DATE);
            $(".con_end_date").html(contract.CON_END_DATE);
            $(".con_ten_date").html(contract.CON_DATE);
            if (!!contract.CON_OUTF_DATE) {
                var str = '<div><span>' + contract.CON_OUTF_DATE + '</span> 至 <span>' + DateUtils.addDay(-1, new Date(contract.CON_HR_DATE)) + '</span></div>';
                $(".con-mzq").append(str);
            }
            if (!!contract.CON_OUTL_DATE) {
                var str = '<div><span>' + DateUtils.addDay(1, new Date(contract.CON_END_DATE)) + '</span> 至 <span>' + contract.CON_OUTL_DATE + '</span></div>';
                $(".con-mzq").append(str);
            }
            if (!contract.CON_OUTF_DATE && !contract.CON_OUTL_DATE) {
                $(".con_mzq").remove();
            }
            $(".rent").html(contract.RENT);
            var unitHtmlStr = "";
            console.log(bill)
            if (!!bill) {
                for (var i = 0; i < bill.length; i++) {
                    var fkfpStr = '';
                    billInfo = bill[i].INFO;
                    if (!billInfo) {
                        billInfo = "";
                    }
                    var lateFee = bill[i].LATE_FEE;
                    if (!lateFee || lateFee == " - ") {
                        lateFee = 0;
                    }
                    if (!bill[i].END_DATE) {
                        bill[i].END_DATE = bill[i].START_DATE;
                    }
                    var str = '<li class="rent-detail-item">\n' +
                        '          <div>\n' +
                        '              <span>' + bill[i].START_DATE + ' - ' + bill[i].END_DATE + '</span>\n' +
                        '          </div>\n' +
                        '          <div>\n' +
                        '              <span>' + bill[i].PAY_DATE + '</span>\n' +
                        '          </div>\n' +
                        '          <div>\n' +
                        '              <span>' + bill[i].TOTAL_PRICE + '</span>\n' +
                        '          </div>\n' +
                        '          <div>\n' +
                        '              <span>' + lateFee + '</span>\n' +
                        '          </div>\n' +
                        '          <div>\n' +
                        '              <span>' + bill[i].BILL_NAME + '</span>\n' +
                        '          </div>\n' +
                        '      </li>';
                    $(".container-rent-detail-list").append(str);
                }
            }


            // $(".attachments").empty();
            if (!!attachment) {
                for (var i = 0; i < attachment.length; i++) {
                    if (attachment[i].TYPE === "4") {
                        var demoListView = $('#demoList');
                        var tr = $(['<tr id="upload-' + (i + 1) + '">'
                            , '<td>财务附件</td>'
                            , '<td>' + attachment[i].NAME + '</td>'
                            , '<td>'
                            , '<a href="http://' + window.location.host + '/' + attachment[i].PATH + '" target="_blank" class=\"layui-btn layui-btn-mini layui-btn-normal\">下载</a>'
                            , '</td>'
                            , '</tr>'].join(''));
                        demoListView.append(tr);
                    } else if (attachment[i].TYPE === "1") {
                        var demoListView = $('#demoList');
                        var tr = $(['<tr id="upload-' + (i + 1) + '">'
                            , '<td>合同附件</td>'
                            , '<td>' + attachment[i].NAME + '</td>'
                            , '<td>'
                            , '<a href="http://' + window.location.host + '/' + attachment[i].PATH + '" target="_blank" class=\"layui-btn layui-btn-mini layui-btn-normal\">下载</a>'
                            , '</td>'
                            , '</tr>'].join(''));
                        demoListView.append(tr);
                    }

                }
            }
            form.render();
        },
        //借款企业信息复制
        initCompanyValue: function (radioName, radioValue) {
            var ro = document.getElementsByName(radioName);
            for (var i = 0; i < ro.length; i++) {
                if (ro[i].value == radioValue) {
                    ro[i].checked = true;
                    break;
                }
            }
            $("input[name=" + radioName + "]").each(function () {
                $(this).attr("disabled", true);
            })
        },
        // 所选项目为非自有的，隐藏不必要信息
        hideContractInfo: function () {
            $(".cq-hide .layui-inline-short").remove();
            $(".cq-hide .layui-inline-long").remove();
        },
        // 设置退租信息
        setThrowLease: function (contract, throwLease) {
            $(".quote-throw-lease").show();
            if (contract.THROW_LEASE_TYPE == 0) {
                $(".tuizu-type").html("到期退租");
            } else if (contract.THROW_LEASE_TYPE == 1) {
                $(".tuizu-type").html("中途退租");
            }
            $(".tuizu-date").html(contract.THROW_LEASE_DATE);
            $(".tuizu-info").html(contract.THROW_LEASE_INFO);
            $.ajax({
                url: "/contract/findThrowLeaseReasonByIDs",
                data: {ID: contract.THROW_LEASE_REASON},
                dataType: "json",
                type: "post",
                async: false,
                success: function (res) {
                    if (res.errcode === "0") {
                        var data = res.data;
                        if (!!data) {
                            for (var i = 0; i < data.length; i++) {
                                var str = '<span>' + data[i].NAME + '</span><br>';
                                $(".tuizu-reason").append(str);
                            }
                        }
                    } else if (res.errcode === "1") {
                        layer.msg(res.errmsg, function () {
                        });
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.error(XMLHttpRequest.status);
                    console.error(XMLHttpRequest.readyState);
                    console.error(textStatus);
                }
            });

            var totalStr = '总计：0.00元（总计应收：0.00元 总计应退：0.00元）';

            if (!!throwLease) {
                var ys = 0;
                var yt = 0;
                for (var i = 0; i < throwLease.length; i++) {
                    var t = "";
                    if (throwLease[i].TYPE == 0) {
                        t = "应收";
                        ys += Number(throwLease[i].MONEY);
                    } else if (throwLease[i].TYPE == 1) {
                        t = "应退";
                        yt += Number(throwLease[i].MONEY);
                    }
                    var str = '<span>' + t + ' ' + Number(throwLease[i].MONEY).toFixed(2) + '元</span> <span>备注：' + throwLease[i].INFO + '</span><br>';
                    $(".tuizu-fee").append(str);
                }
                totalStr = '总计：' + (ys - yt).toFixed(2) + '元（总计应收：' + ys.toFixed(2) + '元 总计应退：' + yt.toFixed(2) + '元）';
            }

            $(".tuizu-total").html(totalStr);

        }
    };
    /**
     * 操作方法集合
     * 使用： operate.function()
     * param: obj传this，调用该方法的对象
     *
     */
    var operate = {
        // 审核通过
        pass: function (obj) {
            layer.prompt({title: '请输入备注', value: ' ', formType: 2}, function (text, index) {
                layer.close(index); // 关闭当前提示框
                var i = parent.layer.getFrameIndex(window.name);
                parent.layer.close(i); // 关闭合同详情提示框
                parent.layer.msg("已通过，备注：" + text);   // 父页面弹出已通过
                //alert(checkType)
                //审核通过
                var checkState = 1;
                if ("退租待审核" == checkType) {
                    checkState = 1;
                }
                if ("作废待审核" == checkType) {
                    checkState = 1;
                }
                if ("变更待审核" == checkType) {
                    checkState = 1;
                }
                $.ajax({
                    url: "/contract/checkcontractPC",
                    data: {id: contractId, checkState: checkState, DETAILS: text, CHECK_STATE: checkType},
                    dataType: "json",
                    type: "post",
                    async: false,
                    success: function (res) {
                        if (res.errcode === "0") {
                        } else if (res.errcode === "1") {
                            layer.msg(res.errmsg, function () {
                            });
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        console.error(XMLHttpRequest.status);
                        console.error(XMLHttpRequest.readyState);
                        console.error(textStatus);
                    }
                });
                window.parent.frames[0].reloadcontractTable();
            });
            return false;
        },
        // 审核不通过
        reject: function (obj) {
            layer.prompt({title: '请输入驳回原因', value: ' ', formType: 2}, function (text, index) {
                layer.close(index); // 关闭当前提示框
                var i = parent.layer.getFrameIndex(window.name);
                parent.layer.close(i); // 关闭合同详情提示框
                parent.layer.msg("已驳回，驳回原因：" + text);   // 父页面弹出已驳回
                //审核不通过
                var checkState = 2;
                $.ajax({
                    url: "/contract/checkcontractPC",
                    data: {id: contractId, checkState: checkState, DETAILS: text, CHECK_STATE: checkType},
                    dataType: "json",
                    type: "post",
                    async: false,
                    success: function (res) {
                        if (res.errcode === "0") {
                        } else if (res.errcode === "1") {
                            layer.msg(res.errmsg, function () {
                            });
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        console.error(XMLHttpRequest.status);
                        console.error(XMLHttpRequest.readyState);
                        console.error(textStatus);
                    }
                });
                window.parent.frames[0].reloadcontractTable();
            });
            return false;
        },
        // 打印合同
        print: function (obj) {
            layer.open({
                type: 2,
                title: '打印合同',
                shadeClose: false,
                shade: [0.3],
                maxmin: true, //开启最大化最小化按钮
                area: ['100%', '100%'],
                scrollbar: false, //屏蔽滚动条
                content: 'contract_print.html?type=0&id=' + contractId
            });
        },
        // 关闭窗口
        cancel: function (obj) {
            var i = parent.layer.getFrameIndex(window.name);
            parent.layer.close(i); // 关闭合同详情提示框
        }
    };

    //打开新增合同的页面-其他信息录入
    function toContractQtAdd() {
        parent.layer.open({
            type: 2,    //弹出类型
            title: '新增其他信息',   //标题
            closeBtn: 1,    //显示关闭按钮
            shade: [0.3],   //遮罩透明度
            area: ['1000px', '90%'],  //打开窗口的宽高
            time: 0,    //几秒后自动关闭，默认0时不关闭
            anim: 1,    //动画效果
            resize: false,  //设置成不允许拉伸
            content: '../../../webhtml/loan/loan_qt_add.html?UUID=' + contractId+ '&isShowType=show'     //iframe的url
        });
        //   $(this).blur(); //移除焦点，防止点击回车按钮造成多次打开
    }
</script>
</body>
</html>